﻿using Capstone.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace Capstone.Services
{
    public class MockDataStore : IDataStore<Item>
    {
        public List<Item> items;
        string[] fillList = new string[] { Properties.Resources.GutSymptom1 };
        string[] emptyList = new string[] { };

        public DatePicker date = new DatePicker();

        public MockDataStore()
        {
            items = new List<Item>()
            {
                //new Item { Id = "GSD 0", Text = Properties.Resources.GutDefault, Description=Properties.Resources.GutDescription, Frequency = Properties.Resources.GutFreq3, Length = 7, Symptoms = fillList, OtherSymptoms = emptyList, SleepSymptoms = emptyList, startDate = date },
                // Item { Id = "Stool_Quality", Text = Properties.Resources.StoolDefault, Description=Properties.Resources.StoolDescription,Length = 7, Symptoms = emptyList, OtherSymptoms = emptyList, SleepSymptoms = emptyList, startDate = date},
                //new Item { Id = "Surveys", Text = "Surveys", Description="Add your surveys here." },
            };


        }

        public async Task<bool> AddItemAsync(Item item)
        {
            items.Add(item);

            return await Task.FromResult(true);
        }



        public async Task<bool> UpdateItemAsync(Item item)
        {
            var oldItem = items.Where((Item arg) => arg.Id == item.Id).FirstOrDefault();
            items.Remove(oldItem);
            items.Add(item);

            return await Task.FromResult(true);
        }

        public async Task<bool> DeleteItemAsync(string id)
        {
            var oldItem = items.Where((Item arg) => arg.Id == id).FirstOrDefault();
            items.Remove(oldItem);

            return await Task.FromResult(true);
        }

        public async Task<Item> GetItemAsync(string id)
        {
            return await Task.FromResult(items.FirstOrDefault(s => s.Id == id));
        }

        public async Task<IEnumerable<Item>> GetItemsAsync(bool forceRefresh = false)
        {
            return await Task.FromResult(items);
        }

      
    }
}